package com.cloudptt.api.product.func.sys;

public class SysStateInfo
{
	public static final int SysState_Begin                        		= 0;
	public static final int SysState_SvrStopState                 		= SysState_Begin + 1;
	public static final int SysState_SvrStartState                 		= SysState_Begin + 2;
	public static final int SysState_HttpGetingState           			= SysState_Begin + 3;
	public static final int SysState_HttpGetSucState           			= SysState_Begin + 4;
	public static final int SysState_HttpAuthingState           		= SysState_Begin + 5;
	public static final int SysState_HttpAuthSucState           		= SysState_Begin + 6;
	public static final int SysState_SipAuthingState           			= SysState_Begin + 7;
	public static final int SysState_SipAuthSucState           			= SysState_Begin + 8;
	public static final int SysState_SipPulishingState           		= SysState_Begin + 9;
	public static final int SysState_SipPulishSucState           		= SysState_Begin + 10;
	public static final int SysState_HttpRefreshingState           		= SysState_Begin + 11;

	public static final int Cause_Begin                        			= 20;
	public static final int Cause_Suc                 		  	    	= Cause_Begin + 1;
	public static final int Cause_Failed                 			    = Cause_Begin + 2;
	public static final int Cause_Timeout                 		    	= Cause_Begin + 3;
	public static final int Cause_Password                 		    	= Cause_Begin + 4;
	public static final int Cause_Unauthorized                 			= Cause_Begin + 5;
	public static final int Cause_Logout                      			= Cause_Begin + 6;
	public static final int Cause_ClearInit                      		= Cause_Begin + 7;
	public static final int Cause_Publish_None                     		= Cause_Begin + 8;
	public static final int Cause_License                     			= Cause_Begin + 9;
	public static final int Cause_RefreshErr                     			= Cause_Begin + 10;

	private int state = SysState_SvrStopState;
	private int cause = Cause_Suc;

	public SysStateInfo(int state,int cause)
	{
		this.state = state;
		this.cause = cause;
	}

	public int getState() {
		return state;
	}

	public int getCause() {
		return cause;
	}

	public String toString()
	{
		StringBuffer strBuf = new StringBuffer(" SysStateInfo ");
		strBuf.append("state = ").append(SysStateInfo.stateTag(state)).append(",");
		strBuf.append("cause = ").append(SysStateInfo.causeTag(cause)).append(".");

		return strBuf.toString();
	}

	public static String causeTag(int type) {
		String tag="unknown";
		switch (type)
		{
			case SysStateInfo.Cause_Begin:
				tag = "Cause_Begin";
				break;
			case SysStateInfo.Cause_Suc:
				tag = "Cause_Suc";
				break;
			case SysStateInfo.Cause_Failed:
				tag = "Cause_Failed";
				break;
			case SysStateInfo.Cause_Timeout:
				tag = "Cause_Timeout";
				break;
			case SysStateInfo.Cause_Password:
				tag = "Cause_Input";
				break;
			case SysStateInfo.Cause_Unauthorized:
				tag = "Cause_Unauthorized";
				break;
			case SysStateInfo.Cause_Logout:
				tag = "Cause_Logout";
				break;
			case SysStateInfo.Cause_ClearInit:
				tag = "Cause_ClearInit";
				break;
			case SysStateInfo.Cause_Publish_None:
				tag = "Cause_Publish_None";
				break;
			default:
				tag = "Cause_Unkwone";
				break;
		}
		return tag;
	}
	public static String stateTag(int type) {
		String tag="unknown";
		switch (type)
		{
			case SysStateInfo.SysState_Begin:
				tag = "SysState_Begin";
				break;
			case SysStateInfo.SysState_SvrStopState:
				tag = "SysState_SvrStopState";
				break;
			case SysStateInfo.SysState_SvrStartState:
				tag = "SysState_SvrStartState";
				break;
			case SysStateInfo.SysState_HttpGetingState:
				tag = "SysState_HttpGetingState";
				break;
			case SysStateInfo.SysState_HttpGetSucState:
				tag = "SysState_HttpGetSucState";
				break;
			case SysStateInfo.SysState_HttpAuthingState:
				tag = "SysState_HttpAuthingState";
				break;
			case SysStateInfo.SysState_HttpAuthSucState:
				tag = "SysState_HttpAuthSucState";
				break;
			case SysStateInfo.SysState_SipAuthingState:
				tag = "SysState_SipAuthingState";
				break;
			case SysStateInfo.SysState_SipAuthSucState:
				tag = "SysState_SipAuthSucState";
				break;
			case SysStateInfo.SysState_SipPulishingState:
				tag = "SysState_SipPulishingState";
				break;
			case SysStateInfo.SysState_SipPulishSucState:
				tag = "SysState_SipPulishSucState";
				break;
			case SysStateInfo.SysState_HttpRefreshingState:
				tag = "SysState_HttpRefreshingState";
				break;
			default:
				tag = "SysState_Unkwone";
				break;
		}
		return tag;
	}
}
